const { theme } = require('../config');

module.exports = {
  setCookieTheme: function (req, res, next) {
    const themeName = req.query.theme || theme.name || req.cookies.theme || '';
    if (themeName) {
      theme.setTheme(themeName);
      res.cookie('theme', themeName);
    }
    next();
  },
  setCheckoutCookieTheme: function (req, res, next) {
    theme.setTheme('system');
    res.cookie('theme', 'system');
    next();
  },
};
